package lis.r1.wyd1;

public class ZliczanieObiekt implements Runnable {

	static Account account = new Account();

	@Override
	public void run() {

		for (int i = 0; i < 10; i++) {
//			synchronized (account) {
				updateAccount();
//			}
		}
	}

	private static synchronized void updateAccount() {

		int temp = account.value;
		try {
			Thread.sleep((int) (Math.random() * 1000));
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		account.value = temp + 1;
		System.out.println(Thread.currentThread().getName() + ": "
				+ account.value);
	}

}
